package com.lanxin.hr.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.lanxin.hr.entity.ZzAccount;
import com.lanxin.hr.mapper.ZzAccountMapper;
import com.lanxin.hr.service.IZzAccountService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author author
 * @since 2025-07-26
 */
@Service
public class ZzAccountServiceImpl extends ServiceImpl<ZzAccountMapper, ZzAccount> implements IZzAccountService {

    @Autowired
    private ZzAccountMapper accountMapper;

    //检查账号是否已经存在
    @Override
    public ZzAccount getAccountByUsername(String username) {
        QueryWrapper<ZzAccount> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("username", username);
        return accountMapper.selectOne(queryWrapper);
    }

    //根据员工id查询账号信息
    @Override
    public ZzAccount getAccountByEid(Integer eid) {
        return accountMapper.selectById(eid);
    }

    //更新账号信息
    @Override
    public int updateAccountById(ZzAccount account) {
        return accountMapper.updateById(account);
    }

    //删除用户账号
    @Override
    public int deleteAccountById(Integer eid) {
        return accountMapper.deleteById(eid);
    }

    //修改密码
    @Override
    public int updatePassword(ZzAccount account) {
        return accountMapper.updatePassword(account);
    }

}
